﻿@using Orchard.ContentManagement;
@using Associativy.Frontends.Models

@model Associativy.Frontends.Models.Pages.Frontends.AssociativyFrontendSearchFormPart
@{
    Script.Require("AssociativyFrontends_AutoComplete").AtFoot();
    Style.Require("jQueryUI_Orchard");
}

@using (Html.BeginForm(null, null, FormMethod.Get, new { @id = "associativy-search-form", action = Url.Action("Associations", ViewContext.RouteData.Values) }))
{
    @Html.HiddenFor(m => m.IsPartialGraph)
    <fieldset>
        @Html.LabelFor(m => m.Labels, T("Search terms"))
        @Html.TextBoxFor(m => m.Labels, new { @class = "text text medium" })
        @Html.ValidationMessageFor(m => m.Labels)
    </fieldset>
    
    <button type="submit">@T("Find associations")</button>
}

@using (Script.Foot())
{
    <script type="text/javascript">
        (function ($) {
            $(function () {
                $.associativy.autoComplete.labels("#@Html.FieldIdFor(m => m.Labels)", "@Url.Action("FetchSimilarLabels", "AutoComplete", new { Area = "Associativy.Frontends", GraphName = Model.As<IEngineConfigurationAspect>().GraphDescriptor.Name })");
            });
        })(jQuery);
    </script>
}